package leetcode.biweekly.week77;

import leetcode.IDebug;

public class Solution1 implements IDebug {

	public int countPrefixes(String[] words, String s) {
		int ans = 0;
		for (int i = 0; i < words.length; i++) {
			String cur = words[i];
			if (is(cur, s)) {
				ans++;
			}
		}
		return ans;
	}

	private boolean is(String word, String s) {
		char[] ws = word.toCharArray();
		char[] cs = s.toCharArray();
		if (ws.length > cs.length) {
			return false;
		}
		for (int i = 0; i < ws.length; i++) {
			if (ws[i] != cs[i]) {
				return false;
			}
		}
		return true;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution1 so = new Solution1();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
